<?php

/**
 * @version     $Id: view.html.php 3 2010-10-08 17:49:35Z obalyuk87@gmail.com $
 * @package     AdminSafe
 * @subpackage  Components
 * @copyright   Copyright (C) 2010 Oleksandr Balyuk (www.boolcast.com)
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL v2
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
// No direct access
defined('_JEXEC') or die('Restricted access');
require_once JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'component' . DS . 'view.php';

/**
 * Description of view
 *
 * @author Oleksandr Balyuk <obalyuk@boolcast.com>
 */
class AdminsafeViewIpblacklist extends AdminsafeView {

    protected $pagination = null;
    protected $log = null;
    protected $lists = null;
    protected $i = 0;

    /**
     * Adds stylesheets and scripts
     */
    protected function _addStylesheetsAndScripts() {
        //
        JHTML::_('stylesheet', 'adminsafe.css', 'administrator/components/com_adminsafe/assets/css/');

        //
        JHTML::_('script', 'adminsafe.js', 'administrator/components/com_adminsafe/assets/js/');
    }

    /**
     * Loads Data
     */
    protected function _loadData() {
        $this->log = $this->get('Data');
        $this->pagination = $this->get('Pagination');
        $this->lists = $this->get('lists');
    }

    /**
     * Prepares data for display
     */
    protected function _prepareDataForDisplay() {
        //
        foreach ($this->log as $item) {
            $item->id = $item->ip_address;
            $item->type = $item->type ? JText::_('Auto Banned') : JText::_('Manual');
            $item->check = JHTML::_('grid.checkedout', $item, (int) $this->i++);
        }
    }

    /**
     * Sets the toolbar
     */
    protected function _setToolBar() {
        JToolBarHelper::title(JText::_('CAS_BANNED_IPS'), 'firewall');
        JToolBarHelper::deleteListX('Selected records will be erased permanently. Continue?');
        JToolBarHelper::spacer();
        $this->_addBackToCPanelButton();
    }

}